import { createSlice } from '@reduxjs/toolkit'

export const counterSlice = createSlice({
  name: 'counter',
  initialState: {
    value: 0,
    articleData:[],
    count:0
  },
  reducers: {
    
    getArticleList:(state,action)=>{
        state.articleData=action.payload.rows
        state.count=action.payload.count
    },
    getArticleDelete:(state,action)=>{
        state.articleData=state.articleData.filter(item=>item.id!==action.payload)
    }
  }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const { getArticleList,getArticleDelete } = counterSlice.actions

export default counterSlice.reducer